//
//  ViewController.m
//  LSL_IJKPlayer
//
//  Created by 大龙 on 18/1/3.
//  Copyright © 2018年 LSL. All rights reserved.
//

#import "ViewController.h"
#import <IJKMediaFramework/IJKFFMoviePlayerController.h>


#import "LSLPlayerView.h"
@interface ViewController ()
@property(nonatomic,strong)IJKFFMoviePlayerController * player;

@property (nonatomic,strong)UIView *view1;
@property (nonatomic,strong)UIView *view2;
@property (nonatomic,strong)UIVisualEffectView *effectView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSURL * url = [NSURL URLWithString:@"rtmp://live.hkstv.hk.lxdns.com/live/hks"];
    
//    IJKFFOptions *options = [IJKFFOptions optionsByDefault]; //使用默认配置
//  
//    self.player = [[IJKFFMoviePlayerController alloc] initWithContentURL:url withOptions:options]; //初始化播放器，播放在线视频或直播(RTMP)
//    self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
//    self.player.view.frame = self.view.bounds;
//    self.player.scalingMode = IJKMPMovieScalingModeAspectFit; //缩放模式
//    self.player.shouldAutoplay = YES; //开启自动播放
//    
//    self.view.autoresizesSubviews = YES;
//    [self.view addSubview:self.player.view];
//    [options setPlayerOptionIntValue:1 forKey:@"videotoolbox"];
    
 

//    LSLPlayerView *playerView =[LSLPlayerView sharePlayerView];
//    playerView.frame =CGRectMake(20, 100, 200, 50);
//    playerView.backgroundColor = [UIColor cyanColor];
//    [self.view addSubview:playerView];
//   [[LSLPlayerView sharePlayerView] setVideoURL:url];
//     [[LSLPlayerView sharePlayerView].player prepareToPlay];
    
    
    // Do any additional setup after loading the view, typically from a nib.
    
    _view1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
    _view1.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_view1];
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    
    //  毛玻璃视图
//    _effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
//    
//    //添加到要有毛玻璃特效的控件中
//    _effectView.frame = _view1.bounds;
//    [_view1 addSubview:_effectView];
    // 使用UIToolbar实现毛玻璃效果，简单粗暴，支持iOS7+
    UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:_view1.bounds];
    toolbar.alpha = 0.97;
    [self.view1 addSubview:toolbar];
    
    
    _view2 = [[UIView alloc] initWithFrame:CGRectMake(100, 300, 200, 200)];
    _view2.backgroundColor = [UIColor redColor];
    [self.view addSubview:_view2];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.backgroundColor =[UIColor blueColor];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake(10, 40, 100,50);
    [self.view addSubview:button];
    

}
- (void)buttonAction:(UIButton *)sender{
    if (sender.selected) {
        _view1.alpha =0;
        
    }else{
        _view1.alpha = 1;
    }
    
    sender.selected = !sender.selected;
    
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
   
    [self.player prepareToPlay];
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated ];
      NSURL * url = [NSURL URLWithString:@"rtmp://live.hkstv.hk.lxdns.com/live/hks"];
//    [IJKVideoViewController presentFromViewController:self withTitle:[NSString stringWithFormat:@"URL: %@", url] URL:url completion:^{
//        //            [self.navigationController popViewControllerAnimated:NO];
//    }];


    
}

-(void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
//    [self.player shutdown];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}





@end
